Split scan-chart into parseChartAndIni + scanChart (breaking) - #21
Merged
elicwhite merged 1 commit intoApr 19, 2026
Merged
Conversation
This was referenced Apr 19, 2026
elicwhite
force-pushed
the
split-parse-and-scan
branch
7 times, most recently
from
April 19, 2026 06:45
0193b44 to
8cb0a1f
Compare
Replace the single `scanChartFolder(files, config?)` entry point with
two functions so editor consumers can stop after parsing and skip the
expensive validation/hashing/asset-scanning step.
parseChartAndIni(files): ParseChartAndIniResult
- file discovery + parseChartFile + scanIni
- returns ParsedChart (with chartBytes/format/iniChartModifiers
attached for downstream hashing) plus the ini scan results
- no hashing, no asset I/O
scanChart(parseResult, files, options?): ScannedChart
- what scanChartFolder used to do, minus the parsing
- calls scanParsedChart for chart hashing + notesData
- then runs the same difficulty / playable / metadata-flatten /
audio / image / video logic, returning the same ScannedChart
shape as before
- ScanChartOptions: { includeMd5?, includeBTrack? }
scanParsedChart(parsedChart, includeBTrack?)
- chart-only hashing + notesData. Same body as the previous
module-level chart-scanner `scanChart`, just taking a parsed
chart instead of (files, ini, btrack) so the parsing step
isn't redone here.
scanChartFolder is removed; ScanChartFolderConfig is removed (replaced
by ScanChartOptions). All other helpers stay where they were —
findChartIssues, getChartHash, legacyGetChartHash, etc. remain in
chart-scanner.ts unchanged.
Validation:
- vitest 278/278 pass
- 78,452-chart chart-edit roundtrip: 78,452/78,453 deeply equal
- 78,046-chart hash baseline: same 3 pre-existing trackname-discovery
diffs vs scan-chart@8.0.1 (independently fixed in #22)
elicwhite
force-pushed
the
split-parse-and-scan
branch
from
April 19, 2026 06:59
8cb0a1f to
16ae187
Compare
elicwhite
marked this pull request as ready for review
April 19, 2026 15:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Split the monolithic
scanChartFolder(files, config?)into two functions so consumers that only need the parsed shape can skip the expensive validation/hashing/asset-scanning step.`scanChartFolder` is preserved as a deprecated 3-line shim:
```ts
/** @deprecated ... back-compat shim */
export function scanChartFolder(files, config?) {
return scanChart(files, parseChartAndIni(files), config)
}
```
So this is not a breaking change — existing callers keep working unchanged (just see a deprecation warning), and new callers can opt into the two-step API to skip hashing when they don't need it.
`ScanChartFolderConfig` and `ScannedChart` interfaces are unchanged. All other helpers — `findChartIssues`, `getChartHash`, `legacyGetChartHash`, the asset scanners — stay where they were.
Review tour
A single commit, 6 files (`interfaces.ts` unchanged):
The reviewer ignoring whitespace will see a much smaller diff in `chart-scanner.ts` than the raw line count suggests.
New API usage
```ts
const parsed = parseChartAndIni(files);
const result = scanChart(files, parsed, { includeBTrack, includeMd5 });
```
For tooling that doesn't need hashes or chart-issue detection, just stop at `parseChartAndIni(files).parsedChart`.
Why `chartBytes` on `ParsedChart`?
scan-chart's current `chartHash` is `blake3(chartBytes ++ ini-modifier name/value pairs)` — it hashes the file contents directly plus the few ini knobs that affect parsing. That format predates the SongHash spec and is what Clone Hero uses today to decide whether an in-game score should reset. Because it consumes the raw bytes, the hashing helper needs them on the `ParsedChart`.
The newer SongHash spec computes the chart-folder hash from metadata strings + duration + per-track BTrack hashes — no raw bytes required. scan-chart does not implement SongHash today; once it does, `chartBytes` can be dropped from `ParsedChart`.
Validation
Related